package com.ruoyi.service.impl;

import java.text.SimpleDateFormat;
import java.util.List;

import com.ruoyi.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.AdvCollectMapper;
import com.ruoyi.domain.AdvCollect;
import com.ruoyi.service.IAdvCollectService;

/**
 * Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-04
 */
@Service
public class AdvCollectServiceImpl implements IAdvCollectService
{
    @Autowired
    private AdvCollectMapper advCollectMapper;

    /**
     * 查询
     *
     * @param advCollect 主键
     * @return
     */
    @Override
    public AdvCollect selectAdvCollectByAdvCollect(Long advCollect)
    {
        return advCollectMapper.selectAdvCollectByAdvCollect(advCollect);
    }

    /**
     * 查询列表
     *
     * @param advCollect
     * @return
     */
    @Override
    public List<AdvCollect> selectAdvCollectList(AdvCollect advCollect)
    {
        return advCollectMapper.selectAdvCollectList(advCollect);
    }

    /**
     * 新增
     *
     * @param advCollect
     * @return 结果
     */
    @Override
    public int insertAdvCollect(AdvCollect advCollect)
    {
        advCollect.setCollectDate(DateUtil.getDate_YYYY_MM_dd_HH_mm_ss());
        return advCollectMapper.insertAdvCollect(advCollect);
    }

    /**
     * 修改
     *
     * @param advCollect
     * @return 结果
     */
    @Override
    public int updateAdvCollect(AdvCollect advCollect)
    {
        return advCollectMapper.updateAdvCollect(advCollect);
    }

    /**
     * 批量删除
     *
     * @param advCollects 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteAdvCollectByAdvCollects(Long[] advCollects)
    {
        try {
            return advCollectMapper.deleteAdvCollectByAdvCollects(advCollects);
        }catch (DataIntegrityViolationException e){
            throw new RuntimeException("请先删除关联数据");
        }
    }

    /**
     * 删除信息
     *
     * @param advCollect 主键
     * @return 结果
     */
    @Override
    public int deleteAdvCollectByAdvCollect(Long advCollect)
    {
        try {
            return advCollectMapper.deleteAdvCollectByAdvCollect(advCollect);
        }catch (DataIntegrityViolationException e){
            throw new RuntimeException("请先删除关联数据");
        }

    }
}
